package com.fare.taluo.conf.system;

import com.fare.taluo.conf.ConfigContainer;
import com.fare.taluo.conf.ConfigLocalLoader;
import com.fare.taluo.conf.PropertiesConfigLocalLoader;


public class DefaultPropertiesLoader extends PropertiesConfigLocalLoader implements ConfigLocalLoader{

	public final static String CONFIG_FILE = "config.properties";

	public String getFileName() {
		return CONFIG_FILE;
	}
	/**
	 * 版本号
	 */
	public static final String PROJECT_VERSION = "project.version";
	/**
	 * 工程的统一导入模板下载地址
	 */
	public static final String PROJECT_TEMPLATES_PATH = "project.excel.template.path";
	public static String getVersion(){
		return ConfigContainer.getInstance().get(PROJECT_VERSION, CONFIG_FILE);
	}

	/**
	 * 问题反馈URL地址配置
	 */
	public static final String PROJECT_FEEDBACK_URL = "project.feedback.url";
	public static String getFeedBackUrl(){
		return ConfigContainer.getInstance().get(PROJECT_FEEDBACK_URL, CONFIG_FILE);
	}
	
	/**
	 * 模板存放天数
	 */
	public static final String PROJECT_EXCEL_DAY = "project.excel.days";
	public static String getExcelDay(){
		return ConfigContainer.getInstance().get(PROJECT_EXCEL_DAY,CONFIG_FILE);
	}
	
	/**
	 * 获得工程统一存放excel模板的路径
	 * @return
	 */
	public static String getAppExcelFilePath(){
		String path = System.getProperty("webapp.root");
		String filePath = ConfigContainer.getInstance().get(PROJECT_TEMPLATES_PATH, CONFIG_FILE);
		if(filePath.startsWith("/")) filePath = filePath.substring(1);
		if(!filePath.endsWith("/")) filePath += "/";
		return path+filePath;
	}
	/**
	 * 获得webapp.root的项目绝对路径
	 * @return
	 */
	public static String getRootPath(){
		return System.getProperty("webapp.root");
	}
}
